<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>axios</title>
  <script src="../js/axios.js"></script>
  <script src="../js/qs.js"></script>
  <script>
    let qs = Qs
    // 配置默认baseURL
    axios.defaults.baseURL= 'http://203.195.246.58:5588'
    // 设置请求拦截器
    axios.interceptors.request.use(config => {
      if(config.method == 'post' && config.url != '/user/login') {
        config.data = qs.stringify(config.data)
        // console.log(config);
      }
      if(config.url == '/category/findAll') {
        config.url = '/user/findAll'
      }
      // Do something before request is sent
      return config;
    },error => {
      // Do something with request error
      return Promise.reject(error);
    });
    // 发送请求
    axios.post('/category/findAll',{name:'zhangsan',age:12})
    // axios.post('/user/login',{username:'admin',password:123321})
  </script>
</head>
<body>
  
</body>
</html>